<template>
	<view class="user-distribution-income rel" :style="{background:pageColor}" v-if="isLoad">
		<view class="bg abs" :style="{background: `linear-gradient(180deg, ${primaryColor} 0%, ${pageColor} 100%)`}">
		</view>
		<view style="height:70rpx"></view>
		<view class="mine-menu-list fill-base pd-lg rel" style="margin-top: 0;">
			<view class="flex-between">
				<view>
					<view class="c-title text-bold" style="font-size: 46rpx;" :style="{color:primaryColor}">
						{{detail.cash}}
					</view>
					<view class="f-caption c-caption">当前余额(元)</view>
				</view>
				<view @tap.stop="toApplyCash('cash')" class="cash-btn flex-center f-mini-title c-base radius"
					:style="{background:primaryColor}">
					提现
				</view>
			</view>
			<view class="flex-warp mt-lg pt-md b-1px-t">
				<view class="item-child flex-center flex-column" :class="[{'b-1px-r':index==0}]"
					v-for="(item, index) in countList" :key="index">
					<view class="f-sm-title c-title text-bold">{{detail[item.key]}}</view>
					<view class="f-icontext c-caption">{{ item.text }}</view>
				</view>
			</view>
		</view>

		<view @tap.stop="$util.goUrl({url:`/userA/pages/distribution/record?type=8`})"
			class="mine-menu-list flex-center fill-base" style="padding:27rpx 28rpx 27rpx 30rpx">
			<view class="flex-center item-icon c-base radius" :style="{background:primaryColor}"><i
					class="iconfont icontixianjilu3"></i></view>
			<view class="ml-md flex-1 flex-between">
				<view class="f-mini-title c-title text-bold">提现记录</view>
				<i class="iconfont icongengduo"></i>
			</view>
		</view>
		<view @tap.stop="$util.goUrl({url:`/technician/pages/income/update-record?type=8`})"
			class="mine-menu-list flex-center fill-base" style="padding:27rpx 28rpx 27rpx 30rpx">
			<view class="flex-center item-icon c-base radius" :style="{background:primaryColor}"><i
					class="iconfont iconyuebiandongjilu"></i></view>
			<view class="ml-md flex-1 flex-between">
				<view class="f-mini-title c-title text-bold">余额修改记录</view>
				<i class="iconfont icongengduo"></i>
			</view>
		</view>

		<view class="space-footer"></view>

	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from "vuex"
	export default {
		components: {},
		data() {
			return {
				countList: [{
					key: 'total_cash',
					text: '累计利润(元)'
				}, {
					key: 'wallet_cash',
					text: '已提现(元)'
				}],
				toolList: [{
					icon: 'iconyongjinliushui',
					text: '我的收益',
					url: '/user/pages/coachbroker/record'
				}, {
					icon: 'iconwodeyaoqing',
					text: '我的邀请',
					url: '/user/pages/coachbroker/team'
				}, {
					icon: 'icontixianjilu',
					text: '提现记录',
					url: '/userA/pages/distribution/record?type=7'
				}],
				dataList: [{
					key: 'today_order_count',
					text: '今日成交订单'
				}, {
					key: 'total_order_count',
					text: '累计成交订单'
				}, {
					key: 'today_coach_count',
					text: '今日新增' + this.$t('action.attendantName')
				}, {
					key: 'total_coach_count',
					text: '累计入驻' + this.$t('action.attendantName')
				}],
				detail: {},
				isLoad: false
			}
		},
		computed: mapState({
			configInfo: state => state.config.configInfo,
			mineInfo: state => state.user.mineInfo,
		}),
		onLoad() {
			this.initIndex()
		},
		// #ifdef H5
		destroyed() {
			// #endif
			// #ifndef H5
			onUnload() {
					// #endif
					this.$util.back()
				},
				onPullDownRefresh() {
					// #ifndef APP-PLUS
					uni.showNavigationBarLoading()
					// #endif
					this.initRefresh();
					uni.stopPullDownRefresh()
				},
				methods: {
					...mapMutations([]),
					async initIndex(refresh = false) {
						this.$util.showLoading()
						this.detail = await this.$api.adminuser.index()
						this.$util.setNavigationBarColor({
							bg: this.primaryColor
						})
						this.isLoad = true
						this.$util.hideAll()
						// #ifdef H5
						if (!refresh) {
							this.$jweixin.hideOptionMenu()
						}
						// #endif
					},
					initRefresh() {
						this.initIndex(true)
					},
					toJump(key, index) {
						let {
							url,
							text
						} = this[key][index]
						this.$util.log(url)
						this.$util.toCheckLogin({
							url
						})
					},
					async toApplyCash(key) {
						let cash = this.detail[key]
						if (cash * 1 == 0) {
							this.$util.showToast({
								title: `暂无可提现金额哦`
							})
							return
						}
						this.$util.goUrl({
							url: `/user/pages/cash-out?type=adminuser`
						})
					}
				}
		}
</script>


<style lang="scss">
	.user-distribution-income {
		.bg {
			width: 100%;
			height: 315rpx;
		}

		// 我的订单/其他
		.mine-menu-list {
			margin: 20rpx 25rpx 0 25rpx;
			border-radius: 18rpx;

			.cash-btn {
				width: 162rpx;
				height: 70rpx;
			}

			.item-child {
				width: 50%;
				margin: 10rpx 0;

				.iconfont {
					font-size: 86rpx;
				}
			}

			.item-child.b-1px-r::after {
				top: 25rpx;
				bottom: 25rpx;
				border-right: 1px solid #C7C7C7;
				color: #C7C7C7;
			}

			.item-icon {
				width: 86rpx;
				height: 86rpx;

				.iconfont {
					font-size: 46rpx;
				}
			}

			.icongengduo {
				color: #8A98AF;
				font-size: 22rpx;
			}
		}
	}
</style>